<?php
namespace app\admin\controller;
use app\admin\controller\BaseController;
use app\common\errcode\AdminErrCode;
use app\common\errcode\AdminErrMsg;
use think\Loader;

class VideoController extends BaseController
{
    protected $videoModel;

    public function __construct()
    {
        parent::__construct();
        $this->videoModel = new \app\admin\model\VideoModel();
    }

    /**
     * 视频列表    
     * @param int    $page          页码
     * @param int    $pagesize      分页数量
     * @param string $status        前测状态
     * @param string $tag           前测标签
     * @param string $userid        上传人
     * @param int    $brand_id      品牌id
     * @param int    $product_id    产品id
     * @param string $name          视频名
     */
    public function index()
    {
        try {
            if($this->request->isPost()){
                $data = $this->request->post();
                return $this->jsonJump(AdminErrCode::SUCCESS,AdminErrMsg::SUCCESS,$this->videoModel->getList($data));
            }    
        } catch (\Exception $e) {
            \app\common\model\CommonModel::savelog($this->userid,$e,$this->request->path());
            return $this->jsonJump(AdminErrCode::SYSTEM_ERROR,AdminErrMsg::SYSTEM_ERROR . ',错误信息:'. $e->getMessage());
        }
    }

    /**
     * 推送记录
     * @param int $id 视频id
     * @param int $page 页码
     * @param int $pagesize 页码大小
     * @return \think\response\Json
     */
    public function log()
    {
        try {
            if($this->request->isPost()){
                $data = $this->request->post();
                $validate = Loader::validate('Video');
                $check = $validate->scene('log')->check($data);
                if(!$check) return $this->jsonJump(AdminErrCode::PARAM_ERROR,AdminErrMsg::PARAM_ERROR.','.$validate->getError());
                return $this->jsonJump(AdminErrCode::SUCCESS,AdminErrMsg::SUCCESS,$this->videoModel->getLog($data));
            }
        } catch (\Exception $e) {
            \app\common\model\CommonModel::savelog($this->userid,$e,$this->request->path());
            return $this->jsonJump(AdminErrCode::SYSTEM_ERROR,AdminErrMsg::SYSTEM_ERROR . ',错误信息:'. $e->getMessage());
        }   
    }
}